import http from "@/api/config/http";
import { IQuery, ITableResponse } from "@/interface/IAxios";
import { fileTemplate } from "../utils";
import { IResolution } from "./types";

export function queryResolution(): Promise<ITableResponse<IResolution>> {
  return http.request({
    url: "/resolution/resolution/query",
    method: "get"
  });
}

export function listResolution(query?: IQuery): Promise<ITableResponse<IResolution>> {
  return http.request({
    url: "/resolution/resolution/list",
    method: "get",
    params: query
  });
}

// 删除resolution
export function delResolution(resolutionId: Array<string>) {
  return http.request({
    url: `/resolution/resolution/${resolutionId}`,
    method: "delete"
  });
}
// 新增resolution
export function addResolution(data: IResolution) {
  return http.request({
    url: "/resolution/resolution",
    method: "post",
    data
  });
}
// 修改resolution
export function updateResolution(data: IResolution) {
  return http.request({
    url: "/resolution/resolution",
    method: "put",
    data
  });
}

type ExportCodeParam = {
  model: string;
  count: number;
};
export const exportCode = (params: ExportCodeParam) => {
  return fileTemplate("/v2/sys/api/auto/id", params);
};
